<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}" placeholder="请输入物料名称" required>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">物料编码:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-code" class="form-control" name="row[code]" type="text" value="{$row.code|htmlentities}" placeholder="留空自动生成">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">物料分类:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-category" class="form-control selectpicker" name="row[category]" required>
                <option value="">请选择分类</option>
                {foreach name="categoryList" item="vo" key="k"}
                <option value="{$k}" {if condition="$row.category eq $k"}selected{/if}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">规格型号:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-spec" class="form-control" name="row[spec]" type="text" value="{$row.spec|htmlentities}" placeholder="请输入规格型号">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单位:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-unit" class="form-control selectpicker" name="row[unit]">
                {foreach name="unitList" item="vo" key="k"}
                <option value="{$k}" {if condition="$row.unit eq $k"}selected{/if}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">颜色:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-color" class="form-control" name="row[color]" type="text" value="{$row.color|htmlentities}" placeholder="请输入颜色">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">材质:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-material_type" class="form-control" name="row[material_type]" type="text" value="{$row.material_type|htmlentities}" placeholder="请输入材质">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">品牌:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-brand" class="form-control" name="row[brand]" type="text" value="{$row.brand|htmlentities}" placeholder="请输入品牌">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">默认供应商:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-default_supplier_id" class="form-control selectpicker" name="row[default_supplier_id]">
                <option value="">请选择默认供应商</option>
                {foreach name="supplierList" item="vo"}
                <option value="{$vo.id}" {if condition="$row.default_supplier_id eq $vo.id"}selected{/if}>{$vo.name}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">当前参考价:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-current_price" class="form-control" name="row[current_price]" type="number" value="{$row.current_price}" step="0.0001" placeholder="0.0000">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">当前库存:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-stock" class="form-control" name="row[stock]" type="number" value="{$row.stock}" step="0.01" placeholder="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">最低库存预警:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-min_stock" class="form-control" name="row[min_stock]" type="number" value="{$row.min_stock}" step="0.01" placeholder="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">最高库存:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-max_stock" class="form-control" name="row[max_stock]" type="number" value="{$row.max_stock}" step="0.01" placeholder="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">安全库存:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-safety_stock" class="form-control" name="row[safety_stock]" type="number" value="{$row.safety_stock}" step="0.01" placeholder="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">采购提前期:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-lead_time" class="form-control" name="row[lead_time]" type="number" value="{$row.lead_time}" placeholder="7">
            <span class="help-block">单位：天</span>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">物料图片:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-image" class="form-control" name="row[image]" type="text" value="{$row.image|htmlentities}" placeholder="请输入图片URL">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">描述:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-description" class="form-control" name="row[description]" rows="3" placeholder="请输入物料描述">{$row.description|htmlentities}</textarea>
        </div>
    </div>
    
    <!-- 供应商报价配置 -->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">供应商报价:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">配置供应商报价</h4>
                </div>
                <div class="panel-body">
                    <div id="supplier-list">
                        {foreach name="materialSuppliers" item="vo" key="k"}
                        <div class="supplier-item" data-index="{$k}">
                            <div class="row">
                                <div class="col-md-3">
                                    <select name="suppliers[{$k}][supplier_id]" class="form-control" required>
                                        <option value="">选择供应商</option>
                                        {foreach name="supplierList" item="supplier"}
                                        <option value="{$supplier.id}" {if condition="$vo.supplier_id eq $supplier.id"}selected{/if}>{$supplier.name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                                <div class="col-md-2">
                                    <input type="number" name="suppliers[{$k}][price]" class="form-control" placeholder="报价" step="0.0001" value="{$vo.price}" required>
                                </div>
                                <div class="col-md-2">
                                    <input type="number" name="suppliers[{$k}][min_order_qty]" class="form-control" placeholder="起订量" step="0.01" value="{$vo.min_order_qty}">
                                </div>
                                <div class="col-md-2">
                                    <input type="number" name="suppliers[{$k}][delivery_days]" class="form-control" placeholder="交货期" value="{$vo.delivery_days}">
                                </div>
                                <div class="col-md-2">
                                    <label class="checkbox-inline">
                                        <input type="checkbox" name="suppliers[{$k}][is_preferred]" value="1" {if condition="$vo.is_preferred eq 1"}checked{/if}> 优先
                                    </label>
                                </div>
                                <div class="col-md-1">
                                    <button type="button" class="btn btn-danger btn-sm remove-supplier">删除</button>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                    <button type="button" class="btn btn-success btn-sm" id="add-supplier">添加供应商</button>
                </div>
            </div>
        </div>
    </div>
    
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-status" class="form-control selectpicker" name="row[status]">
                {foreach name="statusList" item="vo" key="k"}
                <option value="{$k}" {if condition="$row.status eq $k"}selected{/if}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

